---
title: 'document | Cypress Documentation'
description: Get the `window.document` of the page that is currently active.
sidebar_label: document
slug: /api/commands/document
---

<ProductHeading product="app" />

# document

Get the `window.document` of the page that is currently active.

## Syntax

```javascript
cy.document()
cy.document(options)
```

### Usage

<Icon name="check-circle" color="green" /> **Correct Usage**

```javascript
cy.document() // yield the window.document object
```

### Arguments

<Icon name="angle-right" /> **options _(Object)_**

Pass in an options object to change the default behavior of `cy.document()`.

| Option    | Default                                                           | Description                                                                         |
| --------- | ----------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| `log`     | `true`                                                            | Displays the command in the [Command log](/app/core-concepts/open-mode#Command-Log) |
| `timeout` | [`defaultCommandTimeout`](/app/references/configuration#Timeouts) | Time to wait for `cy.document()` to resolve before [timing out](#Timeouts)          |

<HeaderYields />

- `cy.document()` 'yields the `window.document` object.
- `cy.document()` is a query, and it is _safe_ to chain further commands.

## Examples

### No Args

#### Get document and do some work

```javascript
cy.document().then((doc) => {
  // work with document element
})
```

#### Make an assertion about the document

```javascript
cy.document().its('contentType').should('eq', 'text/html')
```

## Rules

<HeaderRequirements />

- `cy.document()` requires being chained off of `cy`.

<HeaderAssertions />

- `cy.document()` will automatically
  [retry](/app/core-concepts/retry-ability) until all chained assertions have
  passed

<HeaderTimeouts />

- `cy.document()` can time out waiting for assertions you've added to pass.

## Command Log

**_Get the document_**

```javascript
cy.document()
```

The command above will display in the Command Log as:

<DocsImage
  src="/img/api/document/get-document-of-application-in-command-log.png"
  alt="Command log document"
/>

When clicking on `document` within the command log, the console outputs the
following:

<DocsImage
  src="/img/api/document/console-yields-the-document-of-aut.png"
  alt="console.log document"
/>

## See also

- [`cy.window()`](/api/commands/window)
